﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.hud.components {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import org.aswing.*;
    import Classes.*;
    import flash.filters.*;
    import Display.*;
    import flash.text.*;
    import Display.aswingui.*;
    import Engine.*;
    import flash.external.*;

    public class HUDZMCButton extends HUDComponent {

        private var m_textField:TextField;
        private var m_btn:SimpleButton;
        private var m_btnEmpty:SimpleButton;
        private var m_ZMCButton:JButton;

        public function HUDZMCButton(){
            ExternalInterface.call("getZMCCounter");
            ExternalInterface.addCallback("refreshZMCCounter", this.onRefreshZMCCounter);
        }
        override protected function buildComponent():void{
            var _local1:Sprite = new Sprite();
            this.addChild(_local1);
            var _local2:AssetPane = ASwingHelper.makeMultilineText("1", 25, EmbeddedArt.TITLE_FONT, "center", 12, 0xFFFFFF);
            this.m_textField = (_local2.getAsset() as TextField);
            ASwingHelper.setEasyBorder(_local2, 9);
            _local2.mouseChildren = false;
            _local2.mouseEnabled = false;
            var _local3:DisplayObject = new EmbeddedArt.zmc_Button();
            var _local4:DisplayObject = new EmbeddedArt.zmc_Button_Empty();
            this.m_btn = new SimpleButton(_local3, _local3, _local3, _local3);
            this.m_btnEmpty = new SimpleButton(_local4, _local4, _local4, _local4);
            this.m_ZMCButton = new JButton();
            this.m_ZMCButton.wrapSimpleButton(this.m_btn);
            var _local5:JWindow = new JWindow(_local1);
            var _local6:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.RIGHT);
            _local6.addEventListener(MouseEvent.CLICK, this.onClickZMCButton);
            _local6.addEventListener(MouseEvent.MOUSE_MOVE, this.onMouseMove);
            _local6.addEventListener(MouseEvent.MOUSE_OUT, this.onMouseOut);
            _local6.appendAll(this.m_ZMCButton, ASwingHelper.horizontalStrut(-22), _local2);
            _local5.setContentPane(_local6);
            ASwingHelper.prepare(_local5);
            _local5.show();
        }
        public function onRefreshZMCCounter(_arg1:Number):void{
            if (_arg1 > 0){
                this.m_textField.text = _arg1.toString();
                this.m_ZMCButton.wrapSimpleButton(this.m_btn);
            } else {
                this.m_textField.text = "";
                this.m_ZMCButton.wrapSimpleButton(this.m_btnEmpty);
            };
        }
        override protected function attachToolTip():void{
            m_toolTip = new ToolTip(function ():String{
                return (ZLoc.t("Main", "zmcButtonToolTip"));
            });
            m_toolTip.attachToolTip(this.m_ZMCButton);
            m_toolTip.hideCursor = true;
        }
        private function onMouseMove(_arg1:MouseEvent):void{
            this.m_ZMCButton.buttonMode = true;
            this.m_ZMCButton.useHandCursor = true;
            var _local2:GlowFilter = new GlowFilter(EmbeddedArt.HOVER_GLOW_COLOR, 1, 8, 8, 5);
            this.m_ZMCButton.filters = [_local2];
        }
        private function onMouseOut(_arg1:MouseEvent):void{
            this.m_ZMCButton.buttonMode = false;
            this.m_ZMCButton.useHandCursor = false;
            this.m_ZMCButton.filters = [];
        }
        private function onClickZMCButton(_arg1:MouseEvent):void{
            var _local2:String = Utilities.trim(this.m_textField.text);
            var _local3:int = int(_local2);
            if ((((_local2.length == 0)) && ((_local3 == 0)))){
                StatsManager.count("zmc-icon-zero-msg");
            } else {
                StatsManager.count("zmc-icon-msg");
            };
            if (Utilities.isFullScreen()){
                SettingsMenu.handleFullscreenToggle();
            };
            this.m_textField.text = "";
            ExternalInterface.call("openZMC");
        }
        override public function refresh(_arg1:Boolean):void{
        }

    }
}//package Display.hud.components 
